package com.zhitan.ems.http.client;

import java.util.Map;

import com.zhitan.ems.common.core.domain.R;
import com.zhitan.ems.common.extra.utils.HttpUtils;
import com.zhitan.ems.http.model.Coordinate;
import com.zhitan.ems.http.model.Location;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.json.JSONUtil;
/**
 * 高德地图服务客户端接口
 */
public interface Amap {
	public static String HOST_URL="http://ditu.amap.com";
    /**
     * 根据经纬度获取详细地址
     * @param longitude 经度
     * @param latitude 纬度
     * @return
     */
	public static  R<Location> getLocation(String longitude, String latitude){
    	 String url = String.format(HOST_URL+"/service/regeo?longitude=%s&latitude=%s",longitude,latitude);
    	 Location data=JSONUtil.toBean(HttpUtils.httpGet(url),  Location.class);
    	 return R.data(data);
    }
    /**
     * 根据经纬度获取详细地址
     * @param coordinate 经纬度对象
     * @return
     */
    public static  R<Map> getLocation(Coordinate coordinate){
    	String url =HOST_URL+"/service/regeo";
    	 Map data=JSONUtil.toBean(HttpUtils.httpGet(url,BeanUtil.beanToMap(coordinate)),  Map.class);
	   	 return R.data(data);
      }

}
